#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: use_json.py 
@version:
@time: 2022/01/05 
"""
import json


def read_json(path: str) -> dict:
    """
    read json file, and transform to dict
    :rtype: object
    """
    with open(path, 'r', encoding='utf-8') as f:
        return json.loads(f.read())


def write_json(path: str, data: dict):
    with open(path, encoding='utf-8', mode='w') as f:
        f.write(json.dumps(data))


def write_allure_env(path, data):
    with open(path, encoding='utf-8', mode='w') as f:
        f.write(data)


def python2jsonfile(path, python_data):
    with open(path, encoding='utf-8', mode="w") as f:
        f.write(json.dumps(python_data))


def jsonfile2python(path):
    with open(path, encoding='utf-8', mode="r") as f:
        return json.loads(f.read())
